package com.springboot.service.impl;

import com.springboot.mapper.AssistantMessageInformMapper;
import com.springboot.mapper.MessageInformMapper;
import com.springboot.mapper.UserLoginFormMapper;
import com.springboot.model.AssistantMessageInform;
import com.springboot.model.MessageInform;
import com.springboot.model.UserLoginForm;
import com.springboot.service.DoctorViewMessageListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;

/**
 * 本业务用于医生查看通知列表
 */
@Service
public class DoctorViewMessageListServiceImpl implements DoctorViewMessageListService {
    @Autowired
    private UserLoginFormMapper userLoginFormMapper;

    @Autowired
    private MessageInformMapper messageInformMapper;

    @Autowired
    private AssistantMessageInformMapper assistantMessageInformMapper;

    //通过用户手机号码查找用户
    @Override
    public UserLoginForm findUserByTel(String userTel)
    {
        UserLoginForm userLoginForm=userLoginFormMapper.selectByTel(userTel);
        return userLoginForm;
    }

    //通过医生id查找这个医生三天内的消息和所有未读的消息
    @Override
    public ArrayList<MessageInform> findMessageListByDoctorId(Integer doctorId)
    {
        ArrayList<MessageInform> messageInforms=messageInformMapper.selectThreeByDoctorId(doctorId);
        return messageInforms;
    }

    //通过用户id查找用户
    @Override
    public UserLoginForm findUserById(Integer userId)
    {
        UserLoginForm userLoginForm=userLoginFormMapper.selectByPrimaryKey(userId);
        return userLoginForm;
    }

    //通过消息id和助理消息标识查找取消预约的这个助理id
    @Override
    public AssistantMessageInform findAssistantByMessage(AssistantMessageInform assistantMessageInform)
    {
        AssistantMessageInform assistantMessage=assistantMessageInformMapper.selectAssistantByMessage(assistantMessageInform);
        return assistantMessage;
    }
}
